<%--
  Created by IntelliJ IDEA.
  User: Doraemon
  Date: 2022/5/22
  Time: 19:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        html {
            height: 100%;
        }
        body {
            height: 100%;
        }
        .container {
            height: 100%;
            background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
        }
        .login-wrapper {
            background-color: #fff;
            width: 358px;
            height: 588px;
            border-radius: 15px;
            padding: 0 50px;
            position: relative;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }
        .header {
            font-size: 38px;
            font-weight: bold;
            text-align: center;
            line-height: 200px;
        }
        .input-item {
            display: block;
            width: 100%;
            margin-bottom: 20px;
            border: 0;
            padding: 10px;
            border-bottom: 1px solid rgb(128, 125, 125);
            font-size: 15px;
            outline: none;
        }
        .input-item::placeholder {
            text-transform: uppercase;
        }
        .btn {
            text-align: center;
            padding: 10px;
            width: 100%;
            margin-top: 40px;
            background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
            color: #fff;
        }
        .msg {
            text-align: center;
            line-height: 88px;
        }
        a {
            text-decoration-line: none;
            color: #abc1ee;
        }
    </style>
    <script>
        /*<![CDATA[*/

        // 获取当前时间
        function genTimestamp() {
            var time = new Date();
            return time.getTime();
        }

        // // 点击获取验证码
        // function changeCode() {
        //     $("#Img").attr("src", "/getVerifyCode?t=" + genTimestamp());
        // }

        // 点击登录
        $("#login_btn").click(function(){
            var username = $("input[name='username']").val();
            var password = $("input[name='password']").val();
            var code = $("input[name='code']").val();
            if(username != "" && password != ""){
                var data = {"username":username, "password": password};
                // console.log(data); return false;
                $.post("/login?code="+code, data, function(res){
                    // console.log(res); return false;
                    if(res.code == 100){
                        alert(res.extend.msg);
                        location.href = "/index";
                    }
                })
            }else{
                alert("用户名和密码未填写！");
            }
        })
        /*]]>*/
    </script>
</head>
<body>
<div class="container">
    <div class="login-wrapper">
        <div class="header">Login</div>
        <div class="form-wrapper">
            <form action="${pageContext.request.contextPath}/login",method="post">
                <div>${msg}</div>
                <input type="text" name="name" placeholder="name" autocomplete="off"  class="input-item">
                <input type="password" name="password" placeholder="password" class="input-item">
                <P>验证码</P><input id="checks" name="code" class="input-text size-L" type="text"  autocomplete="off"  style="width:150px;" />
                <img src="loginGetVerifyCode" alt="" width="100" height="32" class="passcode" style="height:43px;cursor:pointer;" onclick="this.src=this.src+'?'">
                <div class="btn"><input type="submit" value="提交" id="login_btn"></div>
            </form>
        </div>

        <div class="msg">
            Don't have account?
            <a href="${pageContext.request.contextPath}/login/toInsert">Sign up</a>
        </div>
    </div>
</div>

</body>
</html>
